#!/bin/bash

#------------------Create Data------------------
echo "
# loop names	MPI		CUDA-baseline
L-1 		2790.483	21331.233			
L-5		2913.352	34700.643
L-7		3235.7955	15.8032
L-9		3337.358	12234.96
L-15		2132.1023	19.59079
L-16		1773.4375	35.250705
L-17		3587.358	42.050993
L-27		12024.856	45232.085
"> data1




#--------------------------Plot Data----------------------------

gnuplot <<END
reset
set grid xtics ytics mxtics mytics 
set term epslatex color 
set size 1,0.85


#set format "$%g$"
#set format xy "$%g$"

set xlabel " " 
set ylabel "Runtime (mili-seconds)"
#3,2

#set xrange [0:1024]
#set yrange [1:1000]

set style line 1 lt -1 lw 0.3
set key width -4.7
set key box linestyle 1 outside top

set key horiz
#set log x 2
set log y 10
set border lw 2

set output "./Fig.tex"

set auto x
set style data histogram



set style histogram cluster gap 2 
set style fill solid -1 border -1 
#set boxwidth  2.0

set xtic rotate by 0
#set boxwidth 20 relative

plot 'data1' using 2:xtic(1) fill pattern 1 linecolor rgb '#DD0000' ti "MPI (12-core Westmere)",\
     		      '' u 3 linecolor rgb '#0000AA' ti "CUDA-baseline";
END
#'' u 7 fill pattern 4 linecolor rgb '#336600' ti "SKYNET - 1 Node",\

#-----------------------------------------

epstopdf Fig.eps

#-----------------------------------------
echo " \documentclass{article}
\usepackage{graphics}
\usepackage{nopageno}
%\usepackage{mathpazo}
\usepackage{txfonts}
\usepackage[usenames]{color}
	
\begin{document}
	
\begin{center}
  \small{
  \input{./Fig.tex}}
\end{center}
	
\end{document}" > Figure.tex
#-----------------------------------------

pdflatex Figure.tex
pdfcrop Figure.pdf

mv Figure-crop.pdf comparison.pdf

rm -f data* Figure.tex Figure.pdf Figure.log Figure.aux Figure.log Fig.eps Fig.tex Fig.pdf *~
evince comparison.pdf &
